import Point from "./Point";

/** 生成 八方位所搜的坐标 */
export const genSearchArray = (n: Point, space = 1): number[][] => {
    let arr = [];
    for (let x = n.x - space; x <= n.x + space; x++) {
        for (let y = n.y - space; y <= n.y + space; y++) {
            arr.push([x, y]);
        }
    }
    return arr;
};
/** 查找一个点是否在 set 里面 */
export const findPoint = (set: Point[], { x, y }: Point): boolean => {
    return set.some((i) => {
        return x === i.x && y === i.y;
    });
};
